package com.keon.jianbao.ui.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.keon.jianbao.AppContext;
import com.keon.jianbao.R;
import com.keon.jianbao.api.Api;
import com.keon.jianbao.base.BaseActivity;
import com.keon.jianbao.ui.fragment.TweetListFragment;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * Created by keon on 15/10/19.
 */
public class MyTweetActivity extends BaseActivity {
    FragmentManager fragmentManager;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_tweet;
    }

    @Override
    protected int getToolBarTitle() {
        return R.string.my_tweet;
    }

    @Override
    public void initView() {
        fragmentManager = getSupportFragmentManager();
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View v) {

    }

    @Override
    protected void onResume() {
        super.onResume();
        loadData();
    }

    void loadData() {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        TweetListFragment tweetListFragment = new TweetListFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("user_id", Integer.parseInt(AppContext.getInstance().getProperty("user.id").toString()));
        bundle.putInt("type", 3);
        bundle.putInt("page", 1);
        tweetListFragment.setArguments(bundle);
        ft.replace(R.id.my_tweet_list, tweetListFragment).commit();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_my_tweet, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        super.onOptionsItemSelected(item);
        switch (item.getItemId()) {
            case R.id.tweet_publish:
                jump(TweetPublishActivity.class);
                break;
        }
        return true;
    }
}
